fix: improve resource management for file handle and HTTP response handling#1086
fix: improve resource management for file handle and HTTP response handling#1086lxcxjxhx wants to merge 1 commit into
Conversation
|
Hi @lxcxjxhx and thanks for the contribution! I'll review the changes in more detail over the next few days and, if everything looks good, I'll proceed with the merge. One minor note regarding the PR description: I think "resource management improvements" would be a more accurate description than "resource leak fixes", since the previous implementation was generally cleaned up by Python as well. Also, the PEP 343 reference only applies to the |
|
Thanks for the review, @stasinopoulos! Good point on the wording — I'll update the PR description to use Re: the PEP 343 reference — noted, I'll narrow the description to only mention context managers for the \setup.py\ change and call out the explicit close for the HTTP response separately. I'll push the wording update shortly. |
Description
This PR improves resource management in file handle and HTTP response handling:
Type of change
Testing
Tested with Python 3.11 on Windows 11:
Impact
These are resource management improvements — the previous code was generally cleaned up by Python's garbage collector, but explicit cleanup is more robust and avoids relying on GC timing.